package com.dearbinge.opentapi.content.dictionary;

import com.dearbinge.data.api.cart.CartService;
import com.dearbinge.data.api.dictionary.DictionaryService;
import com.dearbinge.utils.ResultMsg;
import com.dearbinge.utils.enums.ResultStatusCodeEnum;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * 数据库字典控制层
 *
 * @author cl
 * @date 2019/1/10
 */
@Api(description = "数据库字典")
@RestController
@RequestMapping("/dictionary")
@CrossOrigin
@EnableAutoConfiguration
public class DictionaryController {

    @Autowired
    private DictionaryService dictionaryService;

    //获取用户角色(头衔)名称
    @ApiOperation(value = "获取用户角色(头衔)名称", notes = "获取用户角色(头衔)名称")
    @RequestMapping(value = "/getUserRole",method = RequestMethod.GET)
    public ResultMsg<List<Map>> getUserRole() {
        try {
            //获取用户角色(头衔)名称
            List<Map> list = dictionaryService.getUserRole();
            return ResultMsg.okData(list, ResultStatusCodeEnum.SUCCESS.getDesc());
        } catch (Exception e) {
            e.printStackTrace();
        }
        return ResultMsg.error(ResultStatusCodeEnum.CODE500.getCode(), ResultStatusCodeEnum.CODE500.getDesc());
    }

//    //获取指定角色类(头衔)下面的角色
//    @ApiOperation(value = "获取指定角色类(头衔)下面的角色", notes = "获取指定角色类(头衔)下面的角色")
//    @ApiImplicitParam(name = "userRoleType", value = "用户角色类", paramType = "query")
//    @RequestMapping(value = "/getUserRoleName",method = RequestMethod.GET)
//    public ResultMsg<List<Map>> getUserRoleName(String userRoleType) {
//        try {
//            //获取用户角色(头衔)名称
//            List<Map> list = dictionaryService.getUserRoleName(userRoleType);
//            return ResultMsg.okData(list, ResultStatusCodeEnum.SUCCESS.getDesc());
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//        return ResultMsg.error(ResultStatusCodeEnum.CODE500.getCode(), ResultStatusCodeEnum.CODE500.getDesc());
//    }
}
